Take Home Exercise 1

A short description of the post.

Ngah Xin Yan https://github.com/nxinyan/
09-08-2021

Background Information

Since the outbreak of COVID-19 in Wuhan, China, it has affected many countries worldwide. COVID-19 is an deadly disease, with a 2% case fatality rate. Indonesia is part of this ongoing COVID-19 pandemic. It reached the country on 2 March 2020 and since then, the number of cases and death rates has remained high. All the cases were spread among 34 provinces in Indonesia. Among all the provinces, DKI JArkarta contributed close to 24% of the cumulative confirmed cases.

Objective

This exercise aims to reveal the spatio-temporal patterns of monthly cumulative confirmed COVID-19 rate and death rate at sub-district level.

Data Used

Installing and Loading the R packages

packages = c('sf', 'tmap', 'tidyverse','tidyr','readxl','openxlsx','dplyr')
for (p in packages){
  if(!require(p, character.only = T)){
    install.packages(p)
  }
  library(p,character.only = T)
}

Data Extraction, Wrangling and Integration

Importing Geospatial Data

The code chunk below will import Indonesia Geospatial layer

jakarta <- st_read(dsn = "data/Geospatial", 
                    layer = "BATAS_DESA_DESEMBER_2019_DUKCAPIL_DKI_JAKARTA")
Reading layer `BATAS_DESA_DESEMBER_2019_DUKCAPIL_DKI_JAKARTA' from data source `C:\nxinyan\IS415\IS415_blog-2\_posts\2021-10-26-take-home-exercise-1\data\Geospatial' 
  using driver `ESRI Shapefile'
Simple feature collection with 269 features and 161 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 106.3831 ymin: -6.370815 xmax: 106.9728 ymax: -5.184322
Geodetic CRS:  WGS 84

Display basic information of the feature class

st_geometry(jakarta)
Geometry set for 269 features 
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 106.3831 ymin: -6.370815 xmax: 106.9728 ymax: -5.184322
Geodetic CRS:  WGS 84
First 5 geometries:

Looking at the associated information in the dataframe

glimpse(jakarta)
Rows: 269
Columns: 162
$ OBJECT_ID  <dbl> 25477, 25478, 25397, 25400, 25378, 25379, 25390, ~
$ KODE_DESA  <chr> "3173031006", "3173031007", "3171031003", "317103~
$ DESA       <chr> "KEAGUNGAN", "GLODOK", "HARAPAN MULIA", "CEMPAKA ~
$ KODE       <dbl> 317303, 317303, 317103, 317103, 310101, 310101, 3~
$ PROVINSI   <chr> "DKI JAKARTA", "DKI JAKARTA", "DKI JAKARTA", "DKI~
$ KAB_KOTA   <chr> "JAKARTA BARAT", "JAKARTA BARAT", "JAKARTA PUSAT"~
$ KECAMATAN  <chr> "TAMAN SARI", "TAMAN SARI", "KEMAYORAN", "KEMAYOR~
$ DESA_KELUR <chr> "KEAGUNGAN", "GLODOK", "HARAPAN MULIA", "CEMPAKA ~
$ JUMLAH_PEN <dbl> 21609, 9069, 29085, 41913, 6947, 7059, 15793, 589~
$ JUMLAH_KK  <dbl> 7255, 3273, 9217, 13766, 2026, 2056, 5599, 1658, ~
$ LUAS_WILAY <dbl> 0.36, 0.37, 0.53, 0.97, 0.93, 0.95, 1.76, 1.14, 0~
$ KEPADATAN  <dbl> 60504, 24527, 54465, 42993, 7497, 7401, 8971, 515~
$ PERPINDAHA <dbl> 102, 25, 131, 170, 17, 26, 58, 13, 113, 178, 13, ~
$ JUMLAH_MEN <dbl> 68, 52, 104, 151, 14, 32, 36, 10, 60, 92, 5, 83, ~
$ PERUBAHAN  <dbl> 20464, 8724, 27497, 38323, 6853, 6993, 15006, 580~
$ WAJIB_KTP  <dbl> 16027, 7375, 20926, 30264, 4775, 4812, 12559, 398~
$ SILAM      <dbl> 15735, 1842, 26328, 36813, 6941, 7057, 7401, 5891~
$ KRISTEN    <dbl> 2042, 2041, 1710, 3392, 6, 0, 3696, 0, 4058, 5130~
$ KHATOLIK   <dbl> 927, 1460, 531, 1082, 0, 0, 1602, 0, 2100, 2575, ~
$ HINDU      <dbl> 15, 9, 42, 127, 0, 0, 622, 0, 25, 27, 0, 9, 115, ~
$ BUDHA      <dbl> 2888, 3716, 469, 495, 0, 2, 2462, 0, 4134, 4740, ~
$ KONGHUCU   <dbl> 2, 1, 5, 1, 0, 0, 10, 0, 9, 10, 0, 4, 1, 1, 4, 0,~
$ KEPERCAYAA <dbl> 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 2, 0, 22, 0, 3, ~
$ PRIA       <dbl> 11049, 4404, 14696, 21063, 3547, 3551, 7833, 2954~
$ WANITA     <dbl> 10560, 4665, 14389, 20850, 3400, 3508, 7960, 2937~
$ BELUM_KAWI <dbl> 10193, 4240, 14022, 20336, 3366, 3334, 7578, 2836~
$ KAWIN      <dbl> 10652, 4364, 13450, 19487, 3224, 3404, 7321, 2791~
$ CERAI_HIDU <dbl> 255, 136, 430, 523, 101, 80, 217, 44, 381, 476, 3~
$ CERAI_MATI <dbl> 509, 329, 1183, 1567, 256, 241, 677, 220, 1197, 9~
$ U0         <dbl> 1572, 438, 2232, 3092, 640, 648, 802, 585, 2220, ~
$ U5         <dbl> 1751, 545, 2515, 3657, 645, 684, 995, 588, 2687, ~
$ U10        <dbl> 1703, 524, 2461, 3501, 620, 630, 1016, 513, 2653,~
$ U15        <dbl> 1493, 521, 2318, 3486, 669, 671, 1106, 548, 2549,~
$ U20        <dbl> 1542, 543, 2113, 3098, 619, 609, 1081, 491, 2313,~
$ U25        <dbl> 1665, 628, 2170, 3024, 639, 582, 1002, 523, 2446,~
$ U30        <dbl> 1819, 691, 2363, 3188, 564, 592, 1236, 478, 2735,~
$ U35        <dbl> 1932, 782, 2595, 3662, 590, 572, 1422, 504, 3034,~
$ U40        <dbl> 1828, 675, 2371, 3507, 480, 486, 1200, 397, 2689,~
$ U45        <dbl> 1600, 607, 2250, 3391, 421, 457, 1163, 365, 2470,~
$ U50        <dbl> 1408, 619, 1779, 2696, 346, 369, 1099, 288, 2129,~
$ U55        <dbl> 1146, 602, 1379, 1909, 252, 318, 979, 235, 1843, ~
$ U60        <dbl> 836, 614, 1054, 1397, 197, 211, 880, 162, 1386, 1~
$ U65        <dbl> 587, 555, 654, 970, 122, 114, 747, 111, 958, 932,~
$ U70        <dbl> 312, 311, 411, 631, 69, 55, 488, 65, 554, 573, 38~
$ U75        <dbl> 415, 414, 420, 704, 74, 61, 577, 38, 717, 642, 37~
$ TIDAK_BELU <dbl> 3426, 1200, 4935, 7328, 1306, 1318, 2121, 973, 50~
$ BELUM_TAMA <dbl> 1964, 481, 2610, 3763, 730, 676, 1278, 732, 3241,~
$ TAMAT_SD   <dbl> 2265, 655, 2346, 2950, 1518, 2054, 1169, 1266, 44~
$ SLTP       <dbl> 3660, 1414, 3167, 5138, 906, 1357, 2236, 852, 585~
$ SLTA       <dbl> 8463, 3734, 12172, 16320, 2040, 1380, 5993, 1570,~
$ DIPLOMA_I  <dbl> 81, 23, 84, 179, 22, 15, 43, 36, 85, 83, 4, 63, 2~
$ DIPLOMA_II <dbl> 428, 273, 1121, 1718, 101, 59, 573, 97, 604, 740,~
$ DIPLOMA_IV <dbl> 1244, 1241, 2477, 4181, 314, 191, 2199, 357, 1582~
$ STRATA_II  <dbl> 74, 46, 166, 315, 10, 8, 168, 8, 63, 92, 5, 174, ~
$ STRATA_III <dbl> 4, 2, 7, 21, 0, 1, 13, 0, 3, 9, 0, 16, 8, 7, 75, ~
$ BELUM_TIDA <dbl> 3927, 1388, 5335, 8105, 1788, 1627, 2676, 1129, 5~
$ APARATUR_P <dbl> 81, 10, 513, 931, 246, 75, 156, 160, 132, 79, 23,~
$ TENAGA_PEN <dbl> 70, 43, 288, 402, 130, 93, 81, 123, 123, 73, 45, ~
$ WIRASWASTA <dbl> 8974, 3832, 10662, 14925, 788, 728, 6145, 819, 12~
$ PERTANIAN  <dbl> 1, 0, 1, 3, 2, 2, 1, 3, 2, 5, 1, 1, 0, 0, 2, 5, 2~
$ NELAYAN    <dbl> 0, 0, 2, 0, 960, 1126, 1, 761, 1, 2, 673, 0, 0, 0~
$ AGAMA_DAN  <dbl> 6, 6, 5, 40, 0, 0, 49, 2, 10, 11, 0, 54, 15, 16, ~
$ PELAJAR_MA <dbl> 4018, 1701, 6214, 9068, 1342, 1576, 3135, 1501, 6~
$ TENAGA_KES <dbl> 28, 29, 80, 142, 34, 26, 60, 11, 48, 55, 16, 68, ~
$ PENSIUNAN  <dbl> 57, 50, 276, 498, 20, 7, 59, 14, 56, 75, 2, 97, 5~
$ LAINNYA    <dbl> 4447, 2010, 5709, 7799, 1637, 1799, 3430, 1368, 7~
$ GENERATED  <chr> "30 Juni 2019", "30 Juni 2019", "30 Juni 2019", "~
$ KODE_DES_1 <chr> "3173031006", "3173031007", "3171031003", "317103~
$ BELUM_     <dbl> 3099, 1032, 4830, 7355, 1663, 1704, 2390, 1213, 5~
$ MENGUR_    <dbl> 4447, 2026, 5692, 7692, 1576, 1731, 3500, 1323, 7~
$ PELAJAR_   <dbl> 3254, 1506, 6429, 8957, 1476, 1469, 3185, 1223, 6~
$ PENSIUNA_1 <dbl> 80, 65, 322, 603, 24, 8, 70, 20, 75, 97, 2, 132, ~
$ PEGAWAI_   <dbl> 48, 5, 366, 612, 223, 72, 65, 143, 73, 48, 15, 89~
$ TENTARA    <dbl> 4, 0, 41, 57, 3, 0, 74, 1, 20, 12, 2, 11, 90, 340~
$ KEPOLISIAN <dbl> 10, 1, 16, 42, 11, 8, 2, 9, 17, 7, 3, 9, 165, 15,~
$ PERDAG_    <dbl> 31, 5, 1, 3, 6, 1, 2, 4, 3, 1, 4, 0, 1, 2, 9, 2, ~
$ PETANI     <dbl> 0, 0, 1, 2, 0, 1, 1, 0, 1, 1, 1, 2, 0, 0, 1, 2, 0~
$ PETERN_    <dbl> 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0~
$ NELAYAN_1  <dbl> 1, 0, 1, 0, 914, 1071, 0, 794, 0, 1, 663, 0, 0, 0~
$ INDUSTR_   <dbl> 7, 3, 4, 3, 1, 3, 0, 0, 1, 7, 0, 0, 2, 2, 1, 3, 1~
$ KONSTR_    <dbl> 3, 0, 2, 6, 3, 8, 1, 6, 1, 5, 10, 0, 2, 5, 7, 4, ~
$ TRANSP_    <dbl> 2, 0, 7, 4, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 6, 3, 2~
$ KARYAW_    <dbl> 6735, 3034, 7347, 10185, 237, 264, 4319, 184, 940~
$ KARYAW1    <dbl> 9, 2, 74, 231, 4, 0, 16, 1, 13, 10, 1, 24, 17, 29~
$ KARYAW1_1  <dbl> 0, 0, 5, 15, 0, 0, 0, 1, 0, 1, 0, 0, 2, 4, 7, 9, ~
$ KARYAW1_12 <dbl> 23, 4, 25, 35, 141, 50, 16, 157, 6, 9, 40, 11, 11~
$ BURUH      <dbl> 515, 155, 971, 636, 63, 218, 265, 55, 1085, 652, ~
$ BURUH_     <dbl> 1, 0, 0, 0, 2, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 2, 1~
$ BURUH1     <dbl> 0, 0, 1, 0, 1, 25, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, ~
$ BURUH1_1   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
$ PEMBANT_   <dbl> 1, 1, 4, 1, 1, 0, 7, 0, 5, 1, 0, 6, 1, 10, 11, 9,~
$ TUKANG     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0~
$ TUKANG_1   <dbl> 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
$ TUKANG_12  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
$ TUKANG__13 <dbl> 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0~
$ TUKANG__14 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
$ TUKANG__15 <dbl> 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0~
$ TUKANG__16 <dbl> 7, 4, 10, 14, 0, 0, 2, 0, 7, 8, 0, 8, 1, 0, 3, 2,~
$ TUKANG__17 <dbl> 1, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1~
$ ANGGOTA1_5 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
$ DOSEN      <dbl> 3, 2, 23, 36, 1, 2, 11, 0, 3, 5, 0, 14, 6, 28, 69~
$ GURU       <dbl> 72, 40, 272, 378, 118, 72, 69, 116, 126, 71, 36, ~
$ PILOT      <dbl> 1, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1~
$ PENGACARA_ <dbl> 4, 1, 8, 22, 0, 0, 5, 0, 5, 4, 0, 4, 3, 12, 24, 2~
$ NOTARIS    <dbl> 0, 0, 3, 5, 0, 0, 4, 0, 0, 0, 0, 5, 0, 5, 10, 3, ~
$ ARSITEK    <dbl> 1, 0, 2, 3, 0, 0, 2, 0, 0, 0, 0, 4, 1, 2, 7, 3, 9~
$ AKUNTA_    <dbl> 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 2~
$ KONSUL_    <dbl> 1, 0, 2, 11, 0, 0, 4, 0, 0, 0, 0, 6, 2, 3, 10, 8,~
$ DOKTER     <dbl> 16, 32, 35, 68, 0, 1, 63, 0, 27, 32, 1, 63, 48, 6~
$ BIDAN      <dbl> 3, 1, 9, 18, 12, 8, 1, 3, 3, 3, 7, 3, 10, 10, 7, ~
$ PERAWAT    <dbl> 7, 0, 25, 44, 12, 10, 3, 6, 12, 20, 6, 7, 26, 16,~
$ APOTEK_    <dbl> 0, 0, 2, 3, 1, 0, 0, 0, 1, 2, 0, 1, 2, 3, 3, 3, 3~
$ PSIKIATER  <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 2, 1~
$ PENYIA_    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0~
$ PENYIA1    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
$ PELAUT     <dbl> 0, 0, 6, 16, 1, 1, 0, 14, 2, 4, 1, 2, 4, 2, 10, 1~
$ PENELITI   <dbl> 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1~
$ SOPIR      <dbl> 65, 3, 94, 123, 0, 1, 61, 0, 76, 79, 0, 63, 44, 1~
$ PIALAN     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
$ PARANORMAL <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0~
$ PEDAGA_    <dbl> 379, 126, 321, 562, 11, 10, 412, 15, 202, 225, 0,~
$ PERANG_    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
$ KEPALA_    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
$ BIARAW_    <dbl> 0, 1, 0, 0, 0, 0, 22, 0, 3, 0, 0, 2, 1, 0, 4, 0, ~
$ WIRASWAST_ <dbl> 1370, 611, 1723, 3099, 131, 119, 1128, 259, 2321,~
$ LAINNYA_12 <dbl> 94, 57, 82, 122, 12, 10, 41, 6, 89, 158, 24, 37, ~
$ LUAS_DESA  <dbl> 25476, 25477, 25396, 25399, 25377, 25378, 25389, ~
$ KODE_DES_3 <chr> "3173031006", "3173031007", "3171031003", "317103~
$ DESA_KEL_1 <chr> "KEAGUNGAN", "GLODOK", "HARAPAN MULIA", "CEMPAKA ~
$ KODE_12    <dbl> 317303, 317303, 317103, 317103, 310101, 310101, 3~
$ geometry   <MULTIPOLYGON [°]> MULTIPOLYGON (((106.8164 -6..., MULT~

Making an interactive map to identify the outer lands

tmap_mode('view')
tm_shape(jakarta)+
  tm_polygons() +
tm_shape(jakarta) +
  tm_fill("KAB_KOTA",
          palette = "RdYlBu")+
  tm_borders()

From the interactive map, it is observed that the outer islands are in dark blue. Since we are not focusing on outer islands, it will be excluded from the dataset

jakarta_n <- jakarta[!(jakarta$KAB_KOTA == "KEPULAUAN SERIBU" ),]

Checking of CRS Code and Reassignment

st_crs(jakarta_n)
Coordinate Reference System:
  User input: WGS 84 
  wkt:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["latitude",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["longitude",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    ID["EPSG",4326]]
jakarta_sf <- st_transform(jakarta_n, 23845)
st_crs(jakarta_sf)
Coordinate Reference System:
  User input: EPSG:23845 
  wkt:
PROJCRS["DGN95 / Indonesia TM-3 zone 54.1",
    BASEGEOGCRS["DGN95",
        DATUM["Datum Geodesi Nasional 1995",
            ELLIPSOID["WGS 84",6378137,298.257223563,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4755]],
    CONVERSION["Indonesia TM-3 zone 54.1",
        METHOD["Transverse Mercator",
            ID["EPSG",9807]],
        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",139.5,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["Scale factor at natural origin",0.9999,
            SCALEUNIT["unity",1],
            ID["EPSG",8805]],
        PARAMETER["False easting",200000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",1500000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["easting (X)",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["northing (Y)",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["Cadastre."],
        AREA["Indonesia - onshore east of 138°E."],
        BBOX[-9.19,138,-1.49,141.01]],
    ID["EPSG",23845]]

Retaining first nine field in DKI Jakarta sf dataframe

dki_jakarta <- select(jakarta_sf, c(1,2,3,4,5,6,7,8,9))
glimpse(dki_jakarta)
Rows: 263
Columns: 10
$ OBJECT_ID  <dbl> 25477, 25478, 25397, 25400, 25390, 25391, 25394, ~
$ KODE_DESA  <chr> "3173031006", "3173031007", "3171031003", "317103~
$ DESA       <chr> "KEAGUNGAN", "GLODOK", "HARAPAN MULIA", "CEMPAKA ~
$ KODE       <dbl> 317303, 317303, 317103, 317103, 317102, 317102, 3~
$ PROVINSI   <chr> "DKI JAKARTA", "DKI JAKARTA", "DKI JAKARTA", "DKI~
$ KAB_KOTA   <chr> "JAKARTA BARAT", "JAKARTA BARAT", "JAKARTA PUSAT"~
$ KECAMATAN  <chr> "TAMAN SARI", "TAMAN SARI", "KEMAYORAN", "KEMAYOR~
$ DESA_KELUR <chr> "KEAGUNGAN", "GLODOK", "HARAPAN MULIA", "CEMPAKA ~
$ JUMLAH_PEN <dbl> 21609, 9069, 29085, 41913, 15793, 33383, 35906, 2~
$ geometry   <MULTIPOLYGON [m]> MULTIPOLYGON (((-3626874 69..., MULT~

Importing Aspatial Data

The Covid-19 Data in Indonesia are in xlsx format, code chunk below will convert the data into a tibble data frame

Extracting the column being analysed:

feb2021 <- select(data1[(data1$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),], c(1,2,3,4,5,28,31))
jan2021 <- select(data2[(data2$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),], c(1,2,3,4,5,28,31))
mar2021 <- select(data3[(data3$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),], c(1,2,3,4,5,28,31))
apr2021 <- select(data4[(data4$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(1,2,3,4,5,28,31))
may2021 <- select(data5[(data5$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(1,2,3,4,5,28,31))
jun2021 <- select(data6[(data6$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(1,2,3,4,5,28,31))
jul2021 <- select(data7[(data7$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),], c(1,2,3,4,5,28,31))
mar2020 <- select(data8[(data8$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),], c(2,3,4,5,6,13,16))
apr2020 <- select(data9[(data9$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(2,3,4,5,6,13,16))
may2020 <- select(data10[(data10$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(2,3,4,5,6,13,16))
jun2020 <- select(data11[(data11$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(2,3,4,5,6,15,18))
jul2020 <- select(data12[(data12$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(1,2,3,4,5,23,26))
aug2020 <- select(data13[(data13$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(1,2,3,4,5,25,28))
sep2020 <- select(data14[(data14$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(1,2,3,4,5,26,29))
oct2020 <- select(data15[(data15$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(1,2,3,4,5,27,30))
nov2020 <- select(data16[(data16$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(1,2,3,4,5,27,30))
dec2020 <- select(data17[(data17$nama_kota != "KEPULAUAN SERIBU" | data8$nama_kota != "KAB.ADM.KEP.SERIBU
"),],  c(1,2,3,4,5,27,30))

Geospatial Data Integration and Removing records with NA with code chunk below:

dki_mar2020 <- left_join(dki_jakarta, mar2020,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_apr2020 <- left_join(dki_jakarta, apr2020,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_may2020 <- left_join(dki_jakarta, may2020,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_jun2020 <- left_join(dki_jakarta, jun2020,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_jul2020 <- left_join(dki_jakarta, jul2020,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_aug2020 <- left_join(dki_jakarta, aug2020,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_sep2020 <- left_join(dki_jakarta, sep2020,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_oct2020 <- left_join(dki_jakarta, oct2020,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_nov2020 <- left_join(dki_jakarta, nov2020,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_dec2020 <- left_join(dki_jakarta, dec2020,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_jan2021 <- left_join(dki_jakarta, jan2021,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_feb2021 <- left_join(dki_jakarta, feb2021,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_mar2021 <- left_join(dki_jakarta, mar2021,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_apr2021 <- left_join(dki_jakarta, apr2021,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_may2021 <- left_join(dki_jakarta, may2021,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_jun2021 <- left_join(dki_jakarta, jun2021,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

dki_jul2021 <- left_join(dki_jakarta, jul2021,
                          by = c("DESA_KELUR" = "nama_kelurahan")) %>%
  drop_na()

Calculate the cumulative confirmed cases rate (i.e. cases per 10000 population) and the cumulative death rate by month with code chunks below:

Cumulative Rate for Cases

dki_mar2020 <- dki_mar2020 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_apr2020 <- dki_apr2020 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_may2020 <- dki_may2020 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_jun2020 <- dki_jun2020 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_jul2020 <- dki_jul2020 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_aug2020 <- dki_aug2020 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_sep2020 <- dki_sep2020 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_oct2020 <- dki_oct2020 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_nov2020 <- dki_nov2020 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_dec2020 <- dki_dec2020 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_jan2021 <- dki_jan2021 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_feb2021 <- dki_feb2021 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_mar2021 <- dki_mar2021 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_apr2021 <- dki_apr2021 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_may2021 <- dki_may2021 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_jun2021 <- dki_jun2021 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

dki_jul2021 <- dki_jul2021 %>%
  mutate(`Cumulative Rate for Cases` = `POSITIF`/(`JUMLAH_PEN`/10000))

Cumulative Rate for Deaths

dki_mar2020 <- dki_mar2020 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_apr2020 <- dki_apr2020 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_may2020 <- dki_may2020 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_jun2020 <- dki_jun2020 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_jul2020 <- dki_jul2020 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_aug2020 <- dki_aug2020 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_sep2020 <- dki_sep2020 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_oct2020 <- dki_oct2020 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_nov2020 <- dki_nov2020 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_dec2020 <- dki_dec2020 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_jan2021 <- dki_jan2021 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_feb2021 <- dki_feb2021 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_mar2021 <- dki_mar2021 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_apr2021 <- dki_apr2021 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_may2021 <- dki_may2021 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_jun2021 <- dki_jun2021 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

dki_jul2021 <- dki_jul2021 %>%
  mutate(`Cumulative Rate for Deaths` = `Meninggal`/(`JUMLAH_PEN`/10000))

Analysis by Month

March 2020

Thematic Map for Cumulative Rates

tmap_mode("plot")
tm_shape(dki_mar2020)+
  tm_fill(c("Cumulative Rate for Cases", "Cumulative Rate for Deaths"),
          style = "quantile",
          palette = "Blues") + 
  tm_layout(main.title = "Cumulative Rates of Covid-19 Cases (left) and Deaths (right) \nby District - March 2020 (Quantile Classification)",
            main.title.position = "center",
            main.title.size = 1,
            legend.height = 0.45, 
            legend.width = 0.35,
            legend.position = c("left","bottom") )+
  tm_borders(alpha = 0.5) +
  tm_compass(type="8star", size = 2) +
  tm_scale_bar(width = 0.15) +
  tm_credits("Source: Source: Health Ministry of Indonesia")

Analytical Map

get.var <- function(vname,df) {
v <- df[vname] %>% st_set_geometry(NULL)
v <- unname(v[,1])
return(v)
}
boxbreaks <- function(v,mult=1.5) {
  qv <- unname(quantile(v))
  iqr <- qv[4] - qv[2]
  upfence <- qv[4] + mult * iqr
  lofence <- qv[2] - mult * iqr
  # initialize break points vector
  bb <- vector(mode="numeric",length=7)
  # logic for lower and upper fences
  if (lofence < qv[1]) {  # no lower outliers
    bb[1] <- lofence
    bb[2] <- floor(qv[1])
  } else {
    bb[2] <- lofence
    bb[1] <- qv[1]
  }
  if (upfence > qv[5]) { # no upper outliers
    bb[7] <- upfence
    bb[6] <- ceiling(qv[5])
  } else {
    bb[6] <- upfence
    bb[7] <- qv[5]
  }
  bb[3:5] <- qv[2:4]
  return(bb)
}